package jp.isisredirect.DreamWaverFirst;

import android.view.ViewGroup;

public class PlayerController extends AccessoryController {

	private boolean mVertical;
	private PlayerFreqController mFreqC1 ;
	private PlayerFreqController mFreqC2 ;
	
	PlayerController(DreamWaverFirstActivity hostActivity, boolean vertical) {
		super(hostActivity);
		mVertical = vertical;
	}

	protected void onAccesssoryAttached() {
		mFreqC1 = new PlayerFreqController(mHostActivity, 0, getResources(), mVertical);
		mFreqC1.attachToView((ViewGroup) findViewById(R.id.playerfreq1));		
		mFreqC2 = new PlayerFreqController(mHostActivity, 6, getResources(), mVertical);
		mFreqC2.attachToView((ViewGroup) findViewById(R.id.playerfreq2));		

		setupPlayButtonController(R.id.playerplayButton);
		setupMuteButtonController(R.id.playermuteButton);
		setupRecButtonController(R.id.playerrecButton);
	}
	
	PlayerPlayButtonController mPlayButton ;
	MuteButtonController mMuteButton;
	RecButtonController mRecButton;
	
	private void setupPlayButtonController(int viewId) {
		mPlayButton = new PlayerPlayButtonController(mHostActivity, 0, getResources(), mVertical);
		mPlayButton.attachToView(findViewById(viewId));
	}
	private void setupMuteButtonController(int viewId) {
		mMuteButton = new MuteButtonController(mHostActivity, 0, getResources(), mVertical);
		mMuteButton.attachToView(findViewById(viewId));
	}
	private void setupRecButtonController(int viewId) {
		mRecButton = new RecButtonController(mHostActivity, 0, getResources(), mVertical);
		mRecButton.attachToView(findViewById(viewId));
	}
	
	/*
	public void sendAllFreq()
	{
		mFreqC1.sendAll((ViewGroup)findViewById(R.id.playerfreq1));
		mFreqC2.sendAll((ViewGroup)findViewById(R.id.playerfreq2));		
	}
	 */
	
	public void resetControls() {
		mPlayButton.resetButton();
		mMuteButton.resetButton();
		mRecButton.resetButton();

	}
	
	public void setFreqSliderPosition(int index, int freq) {
		mFreqC1.setPosition(index, freq);
		mFreqC2.setPosition(index, freq);
	}
}
